<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
    <xsl:output method="xml" indent="yes" encoding="UTF-8"/>
    <xsl:template match="/trip">
        <gpx xmlns="http://www.topografix.com/GPX/1/1"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"
            version="1.1" creator="JFotoGPS">
            <xsl:for-each select="fotos/foto">
                <xsl:variable name="lat" select="lat"/>
                <xsl:variable name="lon" select="lon"/>
                <wpt lat="{$lat}" lon="{$lon}">
                    <time>
                        <xsl:value-of select="@date"/>
                    </time>
                </wpt>
            </xsl:for-each>
            <xsl:for-each select="tracks/track">
                <trk>
                    <name>
                        <xsl:value-of select="@start"/>
                    </name>
                    <trkseg>
                        <xsl:for-each select="point">
                            <xsl:variable name="lat" select="lat"/>
                            <xsl:variable name="lon" select="lon"/>
                            <trkpt lat="{$lat}" lon="{$lon}">
                                <time>
                                    <xsl:value-of select="@date"/>
                                </time>
                            </trkpt>
                        </xsl:for-each>
                    </trkseg>
                </trk>
            </xsl:for-each>
        </gpx>
    </xsl:template>
</xsl:stylesheet>
